package com.guoxin.chapter2.synblockstring2;

public class Service {
	
	private String anyString = new String();

	public void a() {
		try {
			// 将任意对象作为对象监视器
			synchronized (anyString) {
				System.out.println("a begin");
				Thread.sleep(3000);
				System.out.println("a end");
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public synchronized void b(){
		System.out.println("b begin");
		System.out.println("b end");
	}

}
